package br.ufpb.sistcomp.database;

/**
 * Class that contains the data used to manage the database. Example: Scripts
 * and constants.
 * 
 * @author Diego Sousa, www.diegosousa.com
 * @author Renan Oliveira, www.renanoliveira.com
 * @author jafet Galiza
 * @version 2.0
 * @since 23/01/2012
 * 
 *        Copyright (C) 2012 SistComp Empresa Jr.
 */

public class InformationDatabase {

	/*
	 * Database information.
	 */

	public static String NAME_DATABASE = "mycollege.db";
	public static String NAME_BACKUP_DATABASE = "mycollege_backup.db";
	public static int VERSION_DATABASE = 1;

	public static String GETNAME_TABLE_TEACHERS = "teachers";
	public static String ATRIBUTE_TEACHERS_ID_TEACHER = "id_teacher";
	public static String ATRIBUTE_TEACHERS_NAME = "name";
	public static String ATRIBUTE_TEACHERS_MAIL = "mail";
	public static String ATRIBUTE_TEACHERS_PHONE = "phone";
	public static String ATRIBUTE_TEACHERS_CELL = "cell";

	public static final String GETNAME_TABLE_SEMESTERS = "semesters";
	public static String ATRIBUTE_SEMESTERS_ID_SEMESTERS = "id_semester";
	public static String ATRIBUTE_SEMESTERS_NAME = "name";

	public static final String GETNAME_TABLE_DISCIPLINES = "disciplines";
	public static String ATRIBUTE_DISCIPLINES_ID_DISCIPLINES = "id_discipline";
	public static String ATRIBUTE_DISCIPLINES_ID_TEACHER = ATRIBUTE_TEACHERS_ID_TEACHER;
	public static String ATRIBUTE_DISCIPLINES_ID_SEMESTER = ATRIBUTE_SEMESTERS_ID_SEMESTERS;
	public static String ATRIBUTE_DISCIPLINES_NAME = "name";
	public static String ATRIBUTE_DISCIPLINES_HOURS = "hours";
	public static String ATRIBUTE_DISCIPLINES_MEDIA = "media";

	public static final String GETNAME_TABLE_POINTS = "points";
	public static String ATRIBUTE_POINTS_ID_POINT = "id_point";
	public static String ATRIBUTE_POINTS_ID_DISCIPLINE = ATRIBUTE_DISCIPLINES_ID_DISCIPLINES;
	public static String ATRIBUTE_POINTS_VALUES_POINT = "valuesPoint";

	/*
	 * Scripts to remove tables.
	 */

	public static String SCRIPT_DELETE_ALL_TABLE[] = {

	"DROP TABLE IF EXISTS " + GETNAME_TABLE_TEACHERS,
			"DROP TABLE IF EXISTS " + GETNAME_TABLE_DISCIPLINES,
			"DROP TABLE IF EXISTS " + GETNAME_TABLE_SEMESTERS,
			"DROP TABLE IF EXISTS " + GETNAME_TABLE_POINTS };

	public static String SCRIPT_DELETE_TABLE_TEACHERS[] = { "DROP TABLE IF EXISTS "
			+ GETNAME_TABLE_TEACHERS };

	public static String SCRIPT_DELETE_TABLE_DISCIPLINES[] = { "DROP TABLE IF EXISTS "
			+ GETNAME_TABLE_DISCIPLINES };

	public static String SCRIPT_DELETE_TABLE_SEMESTERS[] = { "DROP TABLE IF EXISTS "
			+ GETNAME_TABLE_SEMESTERS };

	public static String SCRIPT_DELETE_TABLE_POINTS[] = { "DROP TABLE IF EXISTS "
			+ GETNAME_TABLE_POINTS };

	/*
	 * Scripts to create tables.
	 */

	public static String SCRIPT_CREATE_ALL_TABLE[] = {

			"CREATE TABLE IF NOT EXISTS " + GETNAME_TABLE_TEACHERS + " ("
					+ ATRIBUTE_TEACHERS_ID_TEACHER
					+ " INTEGER PRIMARY KEY AUTOINCREMENT,"
					+ ATRIBUTE_TEACHERS_NAME + " TEXT UNIQUE NOT NULL,"
					+ ATRIBUTE_TEACHERS_MAIL + " TEXT UNIQUE,"
					+ ATRIBUTE_TEACHERS_PHONE + " TEXT UNIQUE,"
					+ ATRIBUTE_TEACHERS_CELL + " TEXT UNIQUE);",

			"CREATE TABLE IF NOT EXISTS " + GETNAME_TABLE_SEMESTERS + "("
					+ ATRIBUTE_SEMESTERS_ID_SEMESTERS
					+ " INTEGER PRIMARY KEY AUTOINCREMENT,"
					+ ATRIBUTE_SEMESTERS_NAME + " TEXT UNIQUE NOT NULL);",

			"CREATE TABLE IF NOT EXISTS " + GETNAME_TABLE_DISCIPLINES + "("
					+ ATRIBUTE_DISCIPLINES_ID_DISCIPLINES
					+ " INTEGER PRIMARY KEY AUTOINCREMENT,"
					+ ATRIBUTE_DISCIPLINES_ID_TEACHER + " INTEGER,"
					+ ATRIBUTE_DISCIPLINES_ID_SEMESTER + " INTEGER NOT NULL,"
					+ ATRIBUTE_DISCIPLINES_NAME + " TEXT UNIQUE NOT NULL,"
					+ ATRIBUTE_DISCIPLINES_MEDIA + " REAL,"
					+ ATRIBUTE_DISCIPLINES_HOURS + " INTEGER,"
					+ "FOREIGN KEY (" + ATRIBUTE_DISCIPLINES_ID_TEACHER
					+ ") REFERENCES " + GETNAME_TABLE_TEACHERS + ","
					+ "FOREIGN KEY (" + ATRIBUTE_DISCIPLINES_ID_SEMESTER
					+ ") REFERENCES " + GETNAME_TABLE_SEMESTERS + ");",

			"CREATE TABLE IF NOT EXISTS " + GETNAME_TABLE_POINTS + "("
					+ ATRIBUTE_POINTS_ID_POINT
					+ " INTEGER PRIMARY KEY AUTOINCREMENT,"
					+ ATRIBUTE_POINTS_ID_DISCIPLINE + " INTEGER NOT NULL,"
					+ ATRIBUTE_POINTS_VALUES_POINT + " REAL NOT NULL,"
					+ "FOREIGN KEY (" + ATRIBUTE_POINTS_ID_DISCIPLINE
					+ ") REFERENCES " + GETNAME_TABLE_DISCIPLINES + ");"};

	public static String SCRIPT_CREATE_TABLE_TEACHERS[] = {

	"CREATE TABLE IF NOT EXISTS " + GETNAME_TABLE_TEACHERS + " ("
			+ ATRIBUTE_TEACHERS_ID_TEACHER
			+ " INTEGER PRIMARY KEY AUTOINCREMENT," + ATRIBUTE_TEACHERS_NAME
			+ " TEXT UNIQUE NOT NULL," + ATRIBUTE_TEACHERS_MAIL
			+ " TEXT UNIQUE," + ATRIBUTE_TEACHERS_PHONE + " TEXT UNIQUE,"
			+ ATRIBUTE_TEACHERS_CELL + " TEXT UNIQUE);"};

	public static String SCRIPT_CREATE_TABLE_SEMESTERS[] = {

	"CREATE TABLE IF NOT EXISTS " + GETNAME_TABLE_SEMESTERS + "("
			+ ATRIBUTE_SEMESTERS_ID_SEMESTERS
			+ " INTEGER PRIMARY KEY AUTOINCREMENT," + ATRIBUTE_SEMESTERS_NAME
			+ " TEXT UNIQUE NOT NULL);"};

	public static String SCRIPT_CREATE_TABLE_DISCIPLINES[] = {

	"CREATE TABLE IF NOT EXISTS " + GETNAME_TABLE_DISCIPLINES + "("
			+ ATRIBUTE_DISCIPLINES_ID_DISCIPLINES
			+ " INTEGER PRIMARY KEY AUTOINCREMENT,"
			+ ATRIBUTE_DISCIPLINES_ID_TEACHER + " INTEGER,"
			+ ATRIBUTE_DISCIPLINES_ID_SEMESTER + " INTEGER NOT NULL,"
			+ ATRIBUTE_DISCIPLINES_NAME + " TEXT UNIQUE NOT NULL,"
			+ ATRIBUTE_DISCIPLINES_MEDIA + " REAL,"
			+ ATRIBUTE_DISCIPLINES_HOURS + " INTEGER," + "FOREIGN KEY ("
			+ ATRIBUTE_DISCIPLINES_ID_TEACHER + ") REFERENCES "
			+ GETNAME_TABLE_TEACHERS + "," + "FOREIGN KEY ("
			+ ATRIBUTE_DISCIPLINES_ID_SEMESTER + ") REFERENCES "
			+ GETNAME_TABLE_SEMESTERS + ");"};

	public static String SCRIPT_CREATE_TABLE_POINTS[] = {

	"CREATE TABLE IF NOT EXISTS " + GETNAME_TABLE_POINTS + "("
			+ ATRIBUTE_POINTS_ID_POINT + " INTEGER PRIMARY KEY AUTOINCREMENT,"
			+ ATRIBUTE_POINTS_ID_DISCIPLINE + " INTEGER NOT NULL,"
			+ ATRIBUTE_POINTS_VALUES_POINT + " REAL NOT NULL,"
			+ "FOREIGN KEY (" + ATRIBUTE_POINTS_ID_DISCIPLINE + ") REFERENCES "
			+ GETNAME_TABLE_DISCIPLINES + ");"};
}
